package com.yuexun.beilunpatient.ui.registration.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.yuexun.beilunpatient.R;
import com.yuexun.beilunpatient.base.BaseKJActivity;
import com.yuexun.beilunpatient.config.AppConfig;

import org.kymjs.kjframe.KJHttp;
import org.kymjs.kjframe.http.HttpCallBack;
import org.kymjs.kjframe.http.HttpParams;
import org.kymjs.kjframe.utils.PreferenceHelper;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by chenss on 2018/12/29.
 */
public class Act_Registration_Result extends BaseKJActivity {

    @Bind(R.id.tv_result)
    TextView tvResult;

    @Override
    public void setRootView() {
        setContentView(R.layout.act_registration_result);
        ButterKnife.bind(this);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @Override
    public void initData() {
        super.initData();

        tvResult.setText(getIntent().getExtras().getString("result"));
        if(getIntent().getExtras().getString("result").equals("支付成功")){
            String BaseUrl = AppConfig.WEB_ROOT_PAY + "insurePayResult.json?";
            KJHttp client = new KJHttp();
            HttpParams params = new HttpParams();
            params.put("tn", PreferenceHelper.readString(aty, AppConfig.USER_INFO, AppConfig.SENDTN));
            params.put("sessionUuidPatient", PreferenceHelper.readString(aty, AppConfig.USER_INFO, AppConfig.SESSION_ID));
            client.post(BaseUrl, params, new HttpCallBack() {
                @Override
                public void onSuccess(String t) {
                    super.onSuccess(t);
                }

                @Override
                public void onFailure(int errorNo, String strMsg) {
                    super.onFailure(errorNo, strMsg);
                }
            });
        }

    }

    @OnClick({R.id.title_back, R.id.tv_list})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.title_back:
                finish();
                break;
            case R.id.tv_list:
                startActivity(new Intent(aty, Act_My_Registration.class));
                finish();
                break;
        }
    }
}
